home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr13 / tstse13.zip / INSERTF.S < prev    next >
Text File  |  1994-11-26  |  3KB  |  103 lines

  1. /* Corrected InterFile() for SemWare's TSE editor V2.0. To make this
  2.    SAL macro operational, invoke the main menu (F10), choose
  3.    "Macro", choose "Compile" and press Enter at "Execute Macro".
  4.  
  5. ..................................................................
  6. Prof. Timo Salmi      Co-moderator of comp.archives.msdos.announce
  7. Moderating at garbo.uwasa.fi anonymous FTP archives  193.166.120.5
  8. Faculty of Accounting & Industrial Management; University of Vaasa
  9. Internet: ts@uwasa.fi   BBS +(358)-61-3170972; FIN-65101,  Finland
  10. */
  11.  
  12. // The contents of a simple help, tied later to the CtrlAlt-H key
  13. helpdef tHelpData
  14.   title = "INSERTF.S HELP"           // The help's caption
  15.   x = 10                             // Location
  16.   y = 3
  17.   // The actual help text
  18.   " Prof. Timo Salmi's improved InsertFile() procedure "
  19.   ""
  20.   " The SemWare Editor version 2.0 InsertFile() procedure "
  21.   " has a small flaw in it. It treats a mask like C: as "
  22.   " C:\ while EditFile() does not have this flaw. This "
  23.   " macro corrects the problem. "
  24.   ""
  25.   " You can use <F11> to invoke the command menu after "
  26.   " first exiting this help. "
  27.   ""
  28.   " Last updated Sat 26-November-1994 20:07:48 "
  29. end  /* tHelpData */
  30.  
  31. // InsertFile() replacement
  32. proc timoInsertFile()
  33.   string fname[80]
  34.   integer ok = TRUE
  35.   // Choose the insert-file
  36.   if EditFile()
  37.     fname = CurrFilename()
  38.     if FileExists(fname)
  39.       // Arrange a blank line to the original, target file
  40.       PrevFile()
  41.       InsertLine()
  42.       // Mark the entire insert-file to be inserted
  43.       NextFile()
  44.       BegFile()
  45.       UnmarkBlock()
  46.       MarkChar()
  47.       EndFile()
  48.       MarkChar()
  49.       PrevFile()
  50.       // Copy the entire insert-file to the target file
  51.       CopyBlock()
  52.       // Go back to the insert-file
  53.       NextFile()
  54.       // Remove the insert-file from the ring
  55.       QuitFile()
  56.     else
  57.       ok = FALSE
  58.       // Remove the insert-file from the ring
  59.       QuitFile()
  60.     endif
  61.   endif
  62.   //
  63.   if not ok
  64.     Message("File " + fname + " not found Press <Escape>")
  65.   endif
  66. end  /* timoInsertFile */
  67.  
  68. // New keys and menus **************************************************
  69. forward Menu timoInsertFileMenu()
  70. forward proc tDisableNewKeys()
  71.  
  72. // Add the new key definitions
  73. keydef new_keys
  74.   <CtrlAlt 5>      timoInsertFile()
  75.   <CtrlAlt 0>      tDisableNewKeys()
  76.   <CtrlAlt H>      QuickHelp(tHelpData)
  77.   <F11>            timoInsertFileMenu()
  78. end
  79.  
  80. // Disabling the new extra keys ***************************************
  81. proc tDisableNewKeys()
  82.   if YesNo("Disable the extra keys:") == 1 Disable(new_keys) endif
  83. end
  84.  
  85. // The timoInsertFileMenu *********************************************
  86. Menu timoInsertFileMenu()
  87.   Title = "Timo's InsertFile menu"
  88.   Width = 19
  89.   x = 40
  90.   y = 3
  91.   history
  92.   "&InsertFile        <CtrlAlt 5>"   , timoInsertFile()
  93.   "",,Divide
  94.   "Disable &new keys  <CtrlAlt 0>"   , tDisableNewKeys()
  95.   "&Help              <CtrlAlt H>"   , QuickHelp(tHelpData)
  96.   "This Menu         <F11>"
  97. end  /* timoInsertFileMenu */
  98.  
  99. proc Main()
  100.   Enable (new_keys)
  101.   timoInsertFileMenu()
  102. end
  103.